package com.llt.ai.config;

import com.alibaba.cloud.ai.advisor.RetrievalRerankAdvisor;
import com.alibaba.cloud.ai.dashscope.embedding.DashScopeEmbeddingModel;
import com.alibaba.cloud.ai.dashscope.rerank.DashScopeRerankModel;
import org.springframework.ai.vectorstore.SearchRequest;
import org.springframework.ai.vectorstore.SimpleVectorStore;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: llt
 * @Date: 2025/8/5 20:02
 */
@Configuration
public class VectorStoreConfig {
    @Bean
    public VectorStore vectorStore(DashScopeEmbeddingModel embeddingModel) {
        return SimpleVectorStore.builder(embeddingModel).build();
    }

    @Bean
    public RetrievalRerankAdvisor retrievalRerankAdvisor(VectorStore vectorStore, DashScopeRerankModel dashScopeRerankModel) {
        return new RetrievalRerankAdvisor(vectorStore, dashScopeRerankModel, SearchRequest.builder().topK(5).build());
    }
}
